﻿using Infragistics;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using VNet.VisiSuite.Common.Logger;
using VNet.VisiSuite.Controls;
using VNet.VisiSuite.VisiBoard.Common.Helpers;
using VNet.VisiSuite.VisiBoard.Controls;
using VNet.VisiSuite.VisiBoard.Models;
using VNet.VisiSuite.VisiBoard.ViewModels;

namespace VNet.VisiSuite.VisiBoard.Views
{
    public partial class ProductionView : VisiPage
    {
        #region Member Variables

        /*
        private VNetMenuItem _safety;
        private VNetMenuItem _quality;
        private VNetMenuItem _pre_setup;
        private VNetMenuItem _break_lunch;
        */
        private VNetMenuItem _performance_history;
        private VNetMenuItem _downtime;
        private VNetMenuItem _planned_setups;
        private VNetMenuItem _training_videos;
        private VNetMenuItem _open_maintenance;
        #endregion


        public ProductionView()
        {
            InitializeComponent();

            /**
            var tasks_left = new ObservableCollection<VNetMenuItem>();
            tasks_left.Add(_safety = new VNetMenuItem("Safety", "Safety", null, VNetMenuItemType.GreenWhiteTheme, null, "10"));
            tasks_left.Add(_quality = new VNetMenuItem("Quality", "Quality", null, VNetMenuItemType.GreenWhiteTheme, null, "10"));
            tasks_left.Add(_pre_setup = new VNetMenuItem("Pre-Setup", "Pre-Setup", null, VNetMenuItemType.RedWhiteTheme, null, "10"));

            var tasks_right = new ObservableCollection<VNetMenuItem>();
            tasks_right.Add(_break_lunch = new VNetMenuItem("Break / Lunch", "Break / Lunch", null, VNetMenuItemType.BlueWhiteTheme, onBreakLunch));

            _safety.IsEnabled = false;
            _quality.IsEnabled = false;
            _pre_setup.IsEnabled = false;

            _tasks_toolbar.SetTiles("Tasks", tasks_left, tasks_right);
             */

            var info_left = new ObservableCollection<VNetMenuItem>();
            info_left.Add(_performance_history = new VNetMenuItem("Performance History", "Performance History", null, VNetMenuItemType.BlueWhiteTheme, null));
            info_left.Add(_downtime = new VNetMenuItem("Downtime", "Downtime", null, VNetMenuItemType.BlueWhiteTheme, onDowntime));
            info_left.Add(_planned_setups = new VNetMenuItem("Planned\nSetups", "Planned\nSetups", null, VNetMenuItemType.GrayWhiteTheme, null));
            info_left.Add(_training_videos = new VNetMenuItem("Training\rVideos", "Training\rVideos", null, VNetMenuItemType.BlueWhiteTheme, null));

            var info_right = new ObservableCollection<VNetMenuItem>();
            info_right.Add(_open_maintenance = new VNetMenuItem("Open Maintenance", "Open Maintenance", null, VNetMenuItemType.YellowBlackTheme, null));

            _performance_history.IsEnabled = false;
            _downtime.IsEnabled = true;
            _planned_setups.IsEnabled = false;
            _training_videos.IsEnabled = false;
            _open_maintenance.IsEnabled = false;

            _info_toolbar.SetTiles("Info", info_left, info_right);

            var vm = DataContext as ProductionViewModel;
            _production.DataContext = vm;

        }

        private void VisiPage_Loaded(object sender, RoutedEventArgs e)
        {

        }

        public override IList<VNetMenuItem> BottomMenuItems()
        {
            var view_model = DataContext as ProductionViewModel;
            if (view_model == null) return null;

            return view_model.BottomMenuItems;
        }

        private void onDowntime()
        {
            var view_model = DataContext as ProductionViewModel;
            if (view_model != null)
                view_model.showDowntimeScreen();
        }

        /// <summary>
        /// Show the Break / Lunch downtime dialog on Break / Lunch button clicked.
        /// </summary>
        private void onBreakLunch()
        {
            var view_model = DataContext as ProductionViewModel;
            if (view_model != null)
                view_model.showBreakLunchDialog();
        }
    }
}
